package com.panopset.gui.container;

import static com.panopset.Util.*;
import static com.panopset.gui.LookAndFeel.*;

import java.awt.GridLayout;
import java.awt.LayoutManager;

import javax.swing.JRadioButton;

/**
 * Panopset radio button.
 *
 * @author Karl Dinwiddie
 *
 */
public class PanRadioButton extends PanField<JRadioButton> {
    private static final long serialVersionUID = VERSION_SERIAL_NUMBER;

    /**
     * @param title if null, there will be no Titled Border
     * @param label
     * @param toolTipText
     */
    public PanRadioButton(String title, String label, String toolTipText) {
        super(title, toolTipText, Boolean.FALSE.toString(), new GridLayout(1,1));
        ((JRadioButton) getInnerComponent()).setText(label);
    }

    public PanRadioButton(String title, String toolTipText) {
        super(title, toolTipText, Boolean.FALSE.toString(), new GridLayout(1,1));
    }

    public PanRadioButton(String title) {
        this(title, "");
    }

    @Override
    protected JRadioButton createComponent() {
        JRadioButton rtn = new JRadioButton();
        rtn.setBackground(BG_COLOR);
        rtn.setFont(CONTROL_FONT);
        return rtn;
    }

    @Override
    public String getComponentValue() {
        return Boolean.valueOf(getInnerComponent().isSelected()).toString();
    }

    @Override
    public void setComponentValue(String value) {
        getInnerComponent().setSelected(Boolean.parseBoolean(value));
    }

    @Override
    protected LayoutManager createLayout() {
        // TODO Auto-generated method stub
        return null;
    }
}
